/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mx.its.dswII.biblioteca8e.dao;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import mx.its.dswII.biblioteca8e.modelo.Usuario;

/**
 *
 * @author MAXXWELL
 */
@Stateless
public class UsuarioDao extends AbstractDao<Usuario> implements UsuarioDaoLocal {
    @PersistenceContext(unitName = "Biblioteca8E-ejbPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public UsuarioDao() {
        super(Usuario.class);
    }

    @Override
    public boolean findDuplicity(Usuario user) {
        Query q = em.createNamedQuery("Usuario.findDuplicity");
        q.setParameter("nombre",user.getNombre());
        q.setParameter("apellidoMaterno", user.getApellidoMaterno());
        q.setParameter("apellidoPaterno", user.getApellidoPaterno());
        return !q.getResultList().isEmpty();
    }
    
    
    
}
